<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template crc_optimal</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../crc/reference.html#doxygen.crc_8hpp" title="Header &lt;boost/crc.hpp&gt;">
<link rel="prev" href="classboost_1_1crc__basic.html" title="Class template crc_basic">
<link rel="next" href="crc_8hpp_1ac42566db9fbfefa92a02bd987182c7a1.html" title="Type definition crc_ccitt_true_t">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1crc__basic.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../crc/reference.html#doxygen.crc_8hpp"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="crc_8hpp_1ac42566db9fbfefa92a02bd987182c7a1.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="doxygen.classboost_1_1crc__optimal"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template crc_optimal</span></h2>
<p>boost::crc_optimal — Table-driven CRC computer, usable as a function object. </p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../crc/reference.html#doxygen.crc_8hpp" title="Header &lt;boost/crc.hpp&gt;">boost/crc.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> Bits<span class="special">,</span> <span class="identifier">unspecified</span> TruncPoly<span class="special">,</span> <span class="identifier">unspecified</span> InitRem<span class="special">,</span> 
         <span class="identifier">unspecified</span> FinalXor<span class="special">,</span> <span class="keyword">bool</span> ReflectIn<span class="special">,</span> <span class="keyword">bool</span> ReflectRem<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="classboost_1_1crc__optimal.html" title="Class template crc_optimal">crc_optimal</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimaltypes">types</a></span>
  <span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1aa0e229373ceac12cabb3f3cb1b954969"><span class="identifier">value_type</span></a><span class="special">;</span>

  <span class="comment">// <a class="link" href="classboost_1_1crc__optimal.html#id-1_3_10_11_1_4_2_11-bb">public member functions</a></span>
  <span class="keyword">explicit</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a6c378ca53a31264fba1afe360c5d95ca"><span class="identifier">crc_optimal</span></a><span class="special">(</span><span class="identifier">value_type</span> <span class="special">=</span> <span class="identifier">initial_remainder</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">value_type</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1af5ebc14ee4a4ff150b5a2dbe2f1fba3e"><span class="identifier">get_truncated_polynominal</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">value_type</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a77e0d9e0a97fa5f2e35da81a1bd40218"><span class="identifier">get_initial_remainder</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">value_type</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a4bcccdc7a58696d71d5ef084c30e65ac"><span class="identifier">get_final_xor_value</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1acb73aef87989da4a0f3d5d6f739e923b"><span class="identifier">get_reflect_input</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1ac11e98c973ff528443e3a8e152348f74"><span class="identifier">get_reflect_remainder</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">value_type</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a45251badb63e850e3ce8d4af6fc1e698"><span class="identifier">get_interim_remainder</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a55ab397ac9de41044bb780f26b2525da"><span class="identifier">reset</span></a><span class="special">(</span><span class="identifier">value_type</span> <span class="special">=</span> <span class="identifier">initial_remainder</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a99edaaa138a0d07018ff2ac666be18c1"><span class="identifier">process_byte</span></a><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a3c8bb0cbcd481e266ef83afc09605244"><span class="identifier">process_block</span></a><span class="special">(</span><span class="keyword">void</span> <span class="keyword">const</span> <span class="special">*</span><span class="special">,</span> <span class="keyword">void</span> <span class="keyword">const</span> <span class="special">*</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a052a21f5cd1ae33780b072df893f9519"><span class="identifier">process_bytes</span></a><span class="special">(</span><span class="keyword">void</span> <span class="keyword">const</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">value_type</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a53efc8a3b44fe5a19a97853ef92e4e64"><span class="identifier">checksum</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a60652a197a5f1e413394be3878e12f35"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">value_type</span> <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1ab4eac91cf370584ab7de3c20d8bbabb8"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>

  <span class="comment">// public data members</span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">bit_count</span><span class="special">;</span>  <span class="comment">// A copy of <span class="emphasis"><em>Bits</em></span> provided for meta-programming purposes.    </span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="identifier">truncated_polynominal</span><span class="special">;</span>  <span class="comment">// A copy of <span class="emphasis"><em>TruncPoly</em></span> provided for meta-programming purposes. </span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="identifier">initial_remainder</span><span class="special">;</span>  <span class="comment">// A copy of <span class="emphasis"><em>InitRem</em></span> provided for meta-programming purposes. </span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="identifier">final_xor_value</span><span class="special">;</span>  <span class="comment">// A copy of <span class="emphasis"><em>FinalXor</em></span> provided for meta-programming purposes. </span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">reflect_input</span><span class="special">;</span>  <span class="comment">// A copy of <span class="emphasis"><em>ReflectIn</em></span> provided for meta-programming purposes. </span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">reflect_remainder</span><span class="special">;</span>  <span class="comment">// A copy of <span class="emphasis"><em>ReflectRem</em></span> provided for meta-programming purposes. </span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.10.11.2.8.4"></a><h2>Description</h2>
<p>Objects of this type compute the CRC checksum of submitted data, where said data can be entered piecemeal through several different kinds of groupings. Modulo-2 polynomial division steps are performed byte-wise, aided by the use of pre-computation tables. Said division uses the altered algorithm, so any data has to be unaugmented.</p>
<p>

<span style="color: red">&lt;xrefsect&gt;<span style="color: red">&lt;xreftitle&gt;Todo&lt;/xreftitle&gt;</span><span style="color: red">&lt;xrefdescription&gt;<p>Get rid of the default value for <span class="emphasis"><em>TruncPoly</em></span>. Choosing a divisor is an important decision with many factors, so a default is never useful, especially a bad one. </p>
&lt;/xrefdescription&gt;</span>&lt;/xrefsect&gt;</span></p>
<div class="refsect2">
<a name="id-1.3.10.11.2.8.4.4"></a><h3>Template Parameters</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> Bits</pre>
<p>The order of the modulo-2 polynomial divisor. (<span class="emphasis"><em>Width</em></span> from the RMCA) </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">unspecified</span> TruncPoly</pre>
<p>The lowest coefficients of the divisor polynomial. The highest-order coefficient is omitted and always assumed to be 1. Defaults to <code class="computeroutput">0</code>, i.e. the only non-zero term is the implicit one for x<sup><span class="emphasis"><em>Bits</em></span></sup>. (<span class="emphasis"><em>Poly</em></span> from the RMCA) </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">unspecified</span> InitRem</pre>
<p>The (unaugmented) initial state of the polynomial remainder. Defaults to <code class="computeroutput">0</code> if omitted. (<span class="emphasis"><em>Init</em></span> from the RMCA) </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">unspecified</span> FinalXor</pre>
<p>The (XOR) bit-mask to be applied to the output remainder, after possible reflection but before returning. Defaults to <code class="computeroutput">0</code> (i.e. no bit changes) if omitted. (<span class="emphasis"><em>XorOut</em></span> from the RMCA) </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> ReflectIn</pre>
<p>If <code class="computeroutput">true</code>, input bytes are read lowest-order bit first, otherwise highest-order bit first. Defaults to <code class="computeroutput">false</code> if omitted. (<span class="emphasis"><em>RefIn</em></span> from the RMCA) </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> ReflectRem</pre>
<p>If <code class="computeroutput">true</code>, the output remainder is reflected before the XOR-mask. Defaults to <code class="computeroutput">false</code> if omitted. (<span class="emphasis"><em>RefOut</em></span> from the RMCA)</p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.10.11.2.8.4.5"></a><h3>
<a name="doxygen.classboost_1_1crc__optimaltypes"></a><code class="computeroutput">crc_optimal</code> 
        public
       types</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<p>
<span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <a name="doxygen.classboost_1_1crc__optimal_1aa0e229373ceac12cabb3f3cb1b954969"></a><span class="identifier">value_type</span><span class="special">;</span></p>
<p>This type is used for CRC calculations and is the type for any returned checksums and returned or submitted remainders, (truncated) divisors, or XOR masks. It is a built-in unsigned integer type.    </p>
</li></ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.10.11.2.8.4.6"></a><h3>
<a name="id-1_3_10_11_1_4_2_11-bb"></a><code class="computeroutput">crc_optimal</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="doxygen.classboost_1_1crc__optimal_1a6c378ca53a31264fba1afe360c5d95ca"></a><span class="identifier">crc_optimal</span><span class="special">(</span><span class="identifier">value_type</span> init_rem <span class="special">=</span> <span class="identifier">initial_remainder</span><span class="special">)</span><span class="special">;</span></pre>Create a computer, giving an initial remainder if desired. <p>Constructs a <code class="computeroutput"><a class="link" href="classboost_1_1crc__optimal.html" title="Class template crc_optimal">crc_optimal</a></code> object with a particular CRC formula to be processed upon receiving input. The initial remainder may be overridden.</p>
<p>







</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">init_rem</code></span></p></td>
<td><p>The (unaugmented) initial state of the polynomial remainder. Defaults to <a class="link" href="../">initial_remainder</a> if omitted.</p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="../">truncated_polynominal</a> == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1af5ebc14ee4a4ff150b5a2dbe2f1fba3e">get_truncated_polynominal()</a></code> </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="../">initial_remainder</a> == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a77e0d9e0a97fa5f2e35da81a1bd40218">get_initial_remainder()</a></code> </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="../">final_xor_value</a> == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a4bcccdc7a58696d71d5ef084c30e65ac">get_final_xor_value()</a></code> </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="../">reflect_input</a> == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1acb73aef87989da4a0f3d5d6f739e923b">get_reflect_input()</a></code> </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="../">reflect_remainder</a> == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1ac11e98c973ff528443e3a8e152348f74">get_reflect_remainder()</a></code> </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><span class="emphasis"><em>init_rem</em></span> == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a45251badb63e850e3ce8d4af6fc1e698">get_interim_remainder()</a></code> </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput">(<a class="link" href="../">reflect_remainder</a> ? REFLECT(<span class="emphasis"><em>init_rem</em></span>) : <span class="emphasis"><em>init_rem</em></span>) ^ <a class="link" href="../">final_xor_value</a> == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a53efc8a3b44fe5a19a97853ef92e4e64">checksum()</a></code> </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">value_type</span> <a name="doxygen.classboost_1_1crc__optimal_1af5ebc14ee4a4ff150b5a2dbe2f1fba3e"></a><span class="identifier">get_truncated_polynominal</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the (truncated) polynomial divisor.    <p>Returns a representation of the polynomial divisor. The value of the 2<sup>i</sup> bit is the value of the coefficient of the polynomial's x<sup>i</sup> term. The omitted bit for x<sup>(<a class="link" href="../">bit_count</a>)</sup> term is always 1.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The bit-packed list of coefficients. If the bit-length of <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1aa0e229373ceac12cabb3f3cb1b954969">value_type</a> exceeds <a class="link" href="../">bit_count</a>, the values of higher-placed bits should be ignored (even any for x<sup>(<a class="link" href="../">bit_count</a>)</sup>) since they're unregulated.    </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">value_type</span> <a name="doxygen.classboost_1_1crc__optimal_1a77e0d9e0a97fa5f2e35da81a1bd40218"></a><span class="identifier">get_initial_remainder</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return what the polynomial remainder was set to during construction.    <p>Returns a representation of the polynomial remainder before any input has been submitted. The value of the 2<sup>i</sup> bit is the value of the coefficient of the polynomial's x<sup>i</sup> term.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The bit-packed list of coefficients. If the bit-length of <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1aa0e229373ceac12cabb3f3cb1b954969">value_type</a> exceeds <a class="link" href="../">bit_count</a>, the values of higher-placed bits should be ignored since they're unregulated.    </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">value_type</span> <a name="doxygen.classboost_1_1crc__optimal_1a4bcccdc7a58696d71d5ef084c30e65ac"></a><span class="identifier">get_final_xor_value</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the XOR-mask used during output processing.    <p>Returns the mask to be used during creation of a checksum. The mask is used for an exclusive-or (XOR) operation applied bit-wise to the interim remainder representation (after any reflection, if <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1ac11e98c973ff528443e3a8e152348f74">get_reflect_remainder()</a> returns <code class="computeroutput">true</code>).</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The bit-mask. If the bit-length of <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1aa0e229373ceac12cabb3f3cb1b954969">value_type</a> exceeds <a class="link" href="../">bit_count</a>, the values of higher-placed bits should be ignored since they're unregulated.    </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="doxygen.classboost_1_1crc__optimal_1acb73aef87989da4a0f3d5d6f739e923b"></a><span class="identifier">get_reflect_input</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Check if input-bytes will be reflected before processing.    <p>Returns a whether or not a submitted byte will be "reflected" before it is used to update the interim remainder. Only the byte-wise operations <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a99edaaa138a0d07018ff2ac666be18c1">process_byte</a>, <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a3c8bb0cbcd481e266ef83afc09605244">process_block</a>, and <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a052a21f5cd1ae33780b072df893f9519">process_bytes</a> are affected.</p>
<p>
</p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="doxygen.classboost_1_1crc__optimal_1ac11e98c973ff528443e3a8e152348f74"></a><span class="identifier">get_reflect_remainder</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Check if the remainder will be reflected during output processing.    <p>Indicates if the interim remainder will be "reflected" before it is passed to the XOR-mask stage when returning a checksum.</p>
<p>
</p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">value_type</span> <a name="doxygen.classboost_1_1crc__optimal_1a45251badb63e850e3ce8d4af6fc1e698"></a><span class="identifier">get_interim_remainder</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the remainder based from already-processed bits.    <p>Returns a representation of the polynomial remainder after all the input submissions since construction or the last <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a55ab397ac9de41044bb780f26b2525da">reset</a> call. The value of the 2<sup>i</sup> bit is the value of the coefficient of the polynomial's x<sup>i</sup> term. If CRC processing gets interrupted here, retain the value returned, and use it to start up the next CRC computer where you left off (with <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a55ab397ac9de41044bb780f26b2525da">reset(value_type)</a> or construction). The next computer has to have its other parameters compatible with this computer.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The bit-packed list of coefficients. If the bit-length of <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1aa0e229373ceac12cabb3f3cb1b954969">value_type</a> exceeds <a class="link" href="../">bit_count</a>, the values of higher-placed bits should be ignored since they're unregulated. No output processing (reflection or XOR mask) has been applied to the value.    </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1crc__optimal_1a55ab397ac9de41044bb780f26b2525da"></a><span class="identifier">reset</span><span class="special">(</span><span class="identifier">value_type</span> new_rem <span class="special">=</span> <span class="identifier">initial_remainder</span><span class="special">)</span><span class="special">;</span></pre>Change the interim remainder to either a given value or the initial one. <p>Changes the interim polynomial remainder to <span class="emphasis"><em>new_rem</em></span>, purging any influence previously submitted input has had. The value of the 2<sup>i</sup> bit is the value of the coefficient of the polynomial's x<sup>i</sup> term.</p>
<p>


</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">new_rem</code></span></p></td>
<td><p>The (unaugmented) state of the polynomial remainder starting from this point, with no output processing applied. Defaults to <code class="computeroutput">this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a77e0d9e0a97fa5f2e35da81a1bd40218">get_initial_remainder()</a></code> if omitted.</p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><span class="emphasis"><em>new_rem</em></span> == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a45251badb63e850e3ce8d4af6fc1e698">get_interim_remainder()</a></code> </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput">((this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1ac11e98c973ff528443e3a8e152348f74">get_reflect_remainder()</a> ? REFLECT(<span class="emphasis"><em>new_rem</em></span>) : <span class="emphasis"><em>new_rem</em></span>) ^ this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a4bcccdc7a58696d71d5ef084c30e65ac">get_final_xor_value()</a>) == this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a53efc8a3b44fe5a19a97853ef92e4e64">checksum()</a></code> </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1crc__optimal_1a99edaaa138a0d07018ff2ac666be18c1"></a><span class="identifier">process_byte</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">char</span> byte<span class="special">)</span><span class="special">;</span></pre>Submit a single byte for input processing.    <p>Updates the interim remainder with a byte's worth of altered-CRC-division steps. The bits within the byte are processed from the highest place down if <code class="computeroutput">this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1acb73aef87989da4a0f3d5d6f739e923b">get_reflect_input()</a></code> is <code class="computeroutput">false</code>, and lowest place up otherwise.</p>
<p>

</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Any modulo-2 polynomial divisions may use a table of pre-computed remainder changes (as XOR masks) to speed computation when reading data byte-wise. </p></td></tr>
</table></div>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">byte</code></span></p></td>
<td><p>The new input byte.</p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p>The interim remainder is updated though <code class="computeroutput">CHAR_BIT</code> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs.   </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1crc__optimal_1a3c8bb0cbcd481e266ef83afc09605244"></a><span class="identifier">process_block</span><span class="special">(</span><span class="keyword">void</span> <span class="keyword">const</span> <span class="special">*</span> bytes_begin<span class="special">,</span> <span class="keyword">void</span> <span class="keyword">const</span> <span class="special">*</span> bytes_end<span class="special">)</span><span class="special">;</span></pre>Submit a memory block for input processing, iterator-pair style.    <p>Updates the interim remainder with several bytes' worth of altered-CRC-division steps. The bits within each byte are processed from the highest place down if <code class="computeroutput">this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1acb73aef87989da4a0f3d5d6f739e923b">get_reflect_input()</a></code> is <code class="computeroutput">false</code>, and lowest place up otherwise. The bytes themselves are processed starting from the one pointed by <span class="emphasis"><em>bytes_begin</em></span> until <span class="emphasis"><em>bytes_end</em></span> is reached through forward iteration, treating the two pointers as if they point to <code class="computeroutput">unsigned char</code> objects.</p>
<p>




</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Any modulo-2 polynomial divisions may use a table of pre-computed remainder changes (as XOR masks) to speed computation when reading data byte-wise. </p></td></tr>
</table></div>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">bytes_begin</code></span></p></td>
<td><p>The address where the memory block begins. </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">bytes_end</code></span></p></td>
<td><p>Points to one-byte past the address of the memory block's last byte, or <span class="emphasis"><em>bytes_begin</em></span> if no bytes are to be read.</p></td>
</tr>
</tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><span class="emphasis"><em>bytes_end</em></span> has to equal <span class="emphasis"><em>bytes_begin</em></span> if the latter is <code class="computeroutput">NULL</code> or otherwise doesn't point to a valid buffer. </p></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><span class="emphasis"><em>bytes_end</em></span>, if not equal to <span class="emphasis"><em>bytes_begin</em></span>, has to point within or one-byte-past the same buffer <span class="emphasis"><em>bytes_begin</em></span> points into. </p></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><span class="emphasis"><em>bytes_end</em></span> has to be reachable from <span class="emphasis"><em>bytes_begin</em></span> through a finite number of forward byte-pointer increments.</p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p>The interim remainder is updated though <code class="computeroutput">CHAR_BIT * (((unsigned char const *) bytes_end) - ((unsigned char const *) bytes_begin))</code> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs.   </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1crc__optimal_1a052a21f5cd1ae33780b072df893f9519"></a><span class="identifier">process_bytes</span><span class="special">(</span><span class="keyword">void</span> <span class="keyword">const</span> <span class="special">*</span> buffer<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> byte_count<span class="special">)</span><span class="special">;</span></pre>Submit a memory block for input processing, pointer-and-size style.    <p>Updates the interim remainder with several bytes' worth of altered-CRC-division steps. The bits within each byte are processed from the highest place down if <code class="computeroutput">this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1acb73aef87989da4a0f3d5d6f739e923b">get_reflect_input()</a></code> is <code class="computeroutput">false</code>, and lowest place up otherwise. The bytes themselves are processed starting from the one pointed by <span class="emphasis"><em>buffer</em></span>, forward-iterated (as if the pointed-to objects were of <code class="computeroutput">unsigned char</code>) until <span class="emphasis"><em>byte_count</em></span> bytes are read.</p>
<p>



</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Any modulo-2 polynomial divisions may use a table of pre-computed remainder changes (as XOR masks) to speed computation when reading data byte-wise. </p></td></tr>
</table></div>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">buffer</code></span></p></td>
<td><p>The address where the memory block begins. </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">byte_count</code></span></p></td>
<td><p>The number of bytes in the memory block.</p></td>
</tr>
</tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><span class="emphasis"><em>byte_count</em></span> has to equal 0 if <span class="emphasis"><em>buffer</em></span> is <code class="computeroutput">NULL</code> or otherwise doesn't point to valid memory. </p></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p>If <span class="emphasis"><em>buffer</em></span> points within valid memory, then that block has to have at least <span class="emphasis"><em>byte_count</em></span> more valid bytes allocated from that point.</p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p>The interim remainder is updated though <code class="computeroutput">CHAR_BIT * <span class="emphasis"><em>byte_count</em></span></code> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs.   </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">value_type</span> <a name="doxygen.classboost_1_1crc__optimal_1a53efc8a3b44fe5a19a97853ef92e4e64"></a><span class="identifier">checksum</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the checksum of the already-processed bits.    <p>Computes the checksum of all the submitted bits since construction or the last call to <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a55ab397ac9de41044bb780f26b2525da">reset</a>. The checksum will be the raw checksum, i.e. the (interim) remainder after all the modulo-2 polynomial division, plus any output processing.</p>
<p>
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Since checksums are meant to be compared, any higher-placed bits (when the bit-length of <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1aa0e229373ceac12cabb3f3cb1b954969">value_type</a> exceeds <a class="link" href="../">bit_count</a>) will be set to 0.    </p></td></tr>
</table></div>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p><code class="computeroutput">(this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1ac11e98c973ff528443e3a8e152348f74">get_reflect_remainder()</a> ? REFLECT(this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a45251badb63e850e3ce8d4af6fc1e698">get_interim_remainder()</a>) : this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a45251badb63e850e3ce8d4af6fc1e698">get_interim_remainder()</a>) ^ this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a4bcccdc7a58696d71d5ef084c30e65ac">get_final_xor_value()</a></code></p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1crc__optimal_1a60652a197a5f1e413394be3878e12f35"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">char</span> byte<span class="special">)</span><span class="special">;</span></pre>Submit a single byte for input processing, suitable for the STL. <p>Updates the interim remainder with a byte's worth of altered-CRC-division steps. The bits within the byte are processed from the highest place down if <code class="computeroutput">this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1acb73aef87989da4a0f3d5d6f739e923b">get_reflect_input()</a></code> is <code class="computeroutput">false</code>, and lowest place up otherwise. This function is meant to present a function-object interface to code that wants to process a stream of bytes with <code class="computeroutput">std::for_each</code> or similar range-processing algorithms. Since some of these algorithms takes their function object by value, make sure to copy back the result to this object so the updates can be remembered.</p>
<p>

</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Any modulo-2 polynomial divisions may use a table of pre-computed remainder changes (as XOR masks) to speed computation when reading data byte-wise. </p></td></tr>
</table></div>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">byte</code></span></p></td>
<td><p>The new input byte.</p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p>The interim remainder is updated though <code class="computeroutput">CHAR_BIT</code> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">value_type</span> <a name="doxygen.classboost_1_1crc__optimal_1ab4eac91cf370584ab7de3c20d8bbabb8"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the checksum of the already-processed bits, suitable for the STL. <p>Computes the checksum of all the submitted bits since construction or the last call to <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a55ab397ac9de41044bb780f26b2525da">reset</a>. The checksum will be the raw checksum, i.e. the (interim) remainder after all the modulo-2 polynomial division, plus any output processing. This function is meant to present a function-object interface to code that wants to receive data like <code class="computeroutput">std::generate_n</code> or similar data-processing algorithms. Note that if this object is used as a generator multiple times without an intervening mutating operation, the same value will always be returned.</p>
<p>
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Since checksums are meant to be compared, any higher-placed bits (when the bit-length of <a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1aa0e229373ceac12cabb3f3cb1b954969">value_type</a> exceeds <a class="link" href="../">bit_count</a>) will be set to 0. </p></td></tr>
</table></div>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p><code class="computeroutput">(this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1ac11e98c973ff528443e3a8e152348f74">get_reflect_remainder()</a> ? REFLECT(this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a45251badb63e850e3ce8d4af6fc1e698">get_interim_remainder()</a>) : this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a45251badb63e850e3ce8d4af6fc1e698">get_interim_remainder()</a>) ^ this-&gt;<a class="link" href="classboost_1_1crc__optimal.html#doxygen.classboost_1_1crc__optimal_1a4bcccdc7a58696d71d5ef084c30e65ac">get_final_xor_value()</a></code></p></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2001, 2003, 2012 Daryle Walker<p>
        Distributed under the Boost Software License, Version 1.0. (See the accompanying
        file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1crc__basic.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../crc/reference.html#doxygen.crc_8hpp"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="crc_8hpp_1ac42566db9fbfefa92a02bd987182c7a1.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
